package com.example.shiro.util;

/**
 * @author lijilong
 * @version 1.0
 * @Description:
 * @CreateDate 2018/7/5 10:42
 */
public class ResultGenerator {
    private static final String DEFAULT_SUCCESS_MESSAGE = "SUCCESS";

    //成功
    public static ApiResult getSuccessResult() {
        return new ApiResult()
                .setCode(ResultCodeEnum.SUCCESS.getCode())
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }

    public static <T> ApiResult<T> getSuccessResult(T data) {
        return new ApiResult()
                .setCode(ResultCodeEnum.SUCCESS.getCode())
                .setMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }

    public static ApiResult getFailResult(String message) {
        return new ApiResult()
                .setCode(ResultCodeEnum.FAIL.getCode())
                .setMessage(message);
    }

    public static ApiResult getUnauthorizedResult() {
        return new ApiResult()
                .setCode(ResultCodeEnum.UNAUTHORIZED.getCode())
                .setMessage("权限不足！");
    }
}
